/*<summary>
Created By : Preeti
Created On : 10/18/2008
Class Name : Bed_LoadMapper
Used In    : 
------------------------------------------------------------------------
Modification Log  
------------------------------------------------------------------------
Created By        Modified By         Remarks                             
-----------       ------------        ----------------------------------
                                                                          
------------------------------------------------------------------------
</summary>*/


using System.Xml;
using System.Data;
using System;
using Utils;
using System.Data.SqlClient;

namespace AdminController
{
    public class Bed_DataLoader
    {
        public Bed Get_Bed_DATA(string BedID)
        {
            Bed objBed = new Bed();
            ezUtilsAdapter DBL = new ezUtilsAdapter();
            DataChecker dtc = new DataChecker();
            DataSet ds = new DataSet();


            try
            {
                ds = DBL.RunSPReturnDataSet("SP_GetBed", "TR", new SqlParameter("@vchBedID", BedID));
                if (ds.Tables[0].Rows.Count > 0)
                {
                    DataRow dr = ds.Tables[0].Rows[0];
                    objBed.wardID = Convert.ToString(dr["wardID"]);
                    objBed.BedNumber = Convert.ToString(dr["BedNumber"]);
                    objBed.Description = Convert.ToString(dr["Description"]);
                    objBed.BedType = Convert.ToString(dr["BedType"]);
                    objBed.BedStatus = Convert.ToString(dr["BedStatus"]);
                    objBed.Remarks = Convert.ToString(dr["Remarks"]);
                    return objBed;
                }
                else
                {
                    return objBed;
                }
            }
            catch (SqlException ex)
            {
                string errorMessage = String.Format(
                    "An Error Occurred While Loading the Bed Information to the DB. Message: {0}", ex.Message);
                return objBed;
            }
            finally
            {
                DBL.Dispose();
                dtc.Dispose();
                ds.Dispose();

            }
        }

        public void Dispose()
        {
            this.Dispose(true);
            System.GC.SuppressFinalize(this);
        }

        private void Dispose(bool disposing)
        {
        }


    }
}